#include "threads/thread_load_login_log.h"
#include "ui/panel_login_log.h"
#include "data/db_struct.h"
#include "data/global_paramenter.h"
#include "db/base_db_helper.h"
#include "ui/resource.h"

LoginLogThread::LoginLogThread(LoginLogPanel* panel)
        : wxThread()
{
    _panel = panel;
}

void LoginLogThread::OnExit()
{
}

wxThread::ExitCode LoginLogThread::Entry()
{
    g_param._login_log_list.Clean();
//    g_param._login_log_list.OpenSync();

    int db_code = 0;
    char aaa[1000] = {0};
    g_param._database_helper->GetLoginLogData(db_code, g_param._login_log_list, aaa);
    if (db_code != DBO_SUCCESS)
    {
        wxMessageBox(wxString::Format("db err %d\n %s", db_code, aaa), "err");
    }
//    g_param._login_log_list.CloseSync();

    wxThreadEvent event(wxEVT_COMMAND_THREAD, LOAD_LOGINLOG_EVENT);
    wxQueueEvent(_panel, event.Clone());
    return NULL;
}
